﻿using Microsoft.EntityFrameworkCore.Migrations;
using System;
using System.Collections.Generic;

namespace DotNetStar.TheKing.Domain.Migrations
{
    public partial class Addv1_1 : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "UserPointList");

            migrationBuilder.AlterColumn<string>(
                name: "Subject",
                table: "Contents",
                maxLength: 60,
                nullable: true,
                oldClrType: typeof(string),
                oldMaxLength: 60);

            migrationBuilder.AlterColumn<string>(
                name: "Body",
                table: "Contents",
                nullable: true,
                oldClrType: typeof(string));

            migrationBuilder.AddColumn<int>(
                name: "Cost",
                table: "Contents",
                nullable: true);

            migrationBuilder.AddColumn<string>(
                name: "Instruction",
                table: "Contents",
                maxLength: 255,
                nullable: true);

            migrationBuilder.AddColumn<bool>(
                name: "IsLockComment",
                table: "Contents",
                nullable: false,
                defaultValue: false);

            migrationBuilder.AddColumn<bool>(
                name: "IsOriginal",
                table: "Contents",
                nullable: false,
                defaultValue: false);

            migrationBuilder.AddColumn<int>(
                name: "LikeNum",
                table: "Contents",
                nullable: false,
                defaultValue: 0);

            migrationBuilder.AddColumn<string>(
                name: "Url",
                table: "Contents",
                maxLength: 150,
                nullable: true);

            migrationBuilder.CreateTable(
                name: "Attachments",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    Extension = table.Column<string>(maxLength: 8, nullable: false),
                    FileName = table.Column<string>(maxLength: 150, nullable: false),
                    RandomFileName = table.Column<string>(maxLength: 128, nullable: false),
                    ReferenceId = table.Column<string>(maxLength: 128, nullable: false),
                    ReferenceType = table.Column<int>(nullable: false),
                    RelativePath = table.Column<string>(maxLength: 250, nullable: false),
                    Size = table.Column<long>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Attachments", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "UserOperationHistories",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    CreatedTime = table.Column<DateTime>(nullable: false),
                    ObjectId = table.Column<string>(maxLength: 128, nullable: false),
                    Remark = table.Column<string>(maxLength: 500, nullable: true),
                    Type = table.Column<int>(nullable: false),
                    UserId = table.Column<long>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_UserOperationHistories", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "UserPointHistories",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    CreatedTime = table.Column<DateTime>(nullable: false),
                    Exp = table.Column<int>(nullable: false),
                    PointStrategyId = table.Column<string>(maxLength: 20, nullable: false),
                    Remark = table.Column<string>(maxLength: 100, nullable: true),
                    TradingPoints = table.Column<int>(nullable: false),
                    UserId = table.Column<long>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_UserPointHistories", x => x.Id);
                });
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "Attachments");

            migrationBuilder.DropTable(
                name: "UserOperationHistories");

            migrationBuilder.DropTable(
                name: "UserPointHistories");

            migrationBuilder.DropColumn(
                name: "Cost",
                table: "Contents");

            migrationBuilder.DropColumn(
                name: "Instruction",
                table: "Contents");

            migrationBuilder.DropColumn(
                name: "IsLockComment",
                table: "Contents");

            migrationBuilder.DropColumn(
                name: "IsOriginal",
                table: "Contents");

            migrationBuilder.DropColumn(
                name: "LikeNum",
                table: "Contents");

            migrationBuilder.DropColumn(
                name: "Url",
                table: "Contents");

            migrationBuilder.AlterColumn<string>(
                name: "Subject",
                table: "Contents",
                maxLength: 60,
                nullable: false,
                oldClrType: typeof(string),
                oldMaxLength: 60,
                oldNullable: true);

            migrationBuilder.AlterColumn<string>(
                name: "Body",
                table: "Contents",
                nullable: false,
                oldClrType: typeof(string),
                oldNullable: true);

            migrationBuilder.CreateTable(
                name: "UserPointList",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    CreatedTime = table.Column<DateTime>(nullable: false),
                    Exp = table.Column<int>(nullable: false),
                    PointStrategyId = table.Column<string>(maxLength: 20, nullable: false),
                    Remark = table.Column<string>(maxLength: 100, nullable: true),
                    TradingPoints = table.Column<int>(nullable: false),
                    UserId = table.Column<long>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_UserPointList", x => x.Id);
                });
        }
    }
}
